// xc/components/diy/title/countdown.js
Component({
  addGlobalClass: true,
  multipleSlots: true,
  /**
   * 组件的属性列表
   */
  properties: {
    objmodel: {
      type: Object,
      default: null
    }, 
    endtime: {
      type: String,
      value: "2021/3/5 12:06:07"
    }, 
    
  },
  ready(){
    var objmodel =this.data.objmodel     
   if(objmodel&&objmodel.isshow=="1"){
    this.autoexcel();
   }
  },
  /**
   * 组件的初始数据
   */
  data: {    
    intervalid:-1
  },
  lifetimes: {
    attached: function() {
      // 在组件实例进入页面节点树时执行
      this.autoexcel();
    },
    detached: function() {
      // 在组件实例被从页面节点树移除时执行
      this.clearauto();
    },
    show: function() {
      // 页面被展示
      this.autoexcel();
    },
    hide: function() {
      this.clearauto();
      // 页面被隐藏
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    clearauto: function () {
      var that = this;
      if (that.data.intervalid != -1) {
        clearInterval(that.data.intervalid)
        that.data.intervalid = -1;
  
      }
    },
    autoexcel: function (rest) {
      var that = this;  

      if(!rest){
         if(that.data.intervalid!=-1){
           return ;
         }
      }
      else
      {
        this.clearauto();
      }     
      that.data.intervalid = setInterval(function () {
        
        that.setData({aunttime:new Date()})        
      }, 1000)
  
  
    },
  }
})
